home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 7: Sunsite
/
Linux Cubed Series 7 - Sunsite Vol 1.iso
/
system
/
serial
/
dcon0.000
/
dcon0
/
dcon0.96
/
tst.scr
< prev
Wrap
Text File
|
1996-07-20
|
4KB
|
160 lines
# dcon script to exercise it.
goto testgoto
print "Goto doesn't work!!!\n"
exit 1
:testgoto
goto forward
:backabit
goto continue
:forward
goto backabit
:continue
goto ok
:error
print " error!\n"
print "Strings:\n"
print "$a: ",$a,"\n"
print "$b: ",$b,"\n"
print "$c: ",$c,"\n"
print "$d: ",$d,"\n"
print "$e: ",$e,"\n"
print "$f: ",$f,"\n"
print "$g: ",$g,"\n"
print "$h: ",$h,"\n"
exit 1
:back
goto ok3
:routine2
return
:routine
gosub routine2
return
:ok
if 1=1 sleep 0 goto ok2
print "Integer comparison or compound statements"
goto error
:ok2
goto back
:ok3
gosub routine
if 1=1 let a=0
if 1=1 then let a=0
else print "Else" goto error
if 1=0 print "1=0" goto error
else goto ok4
print "Else" goto error
:ok4
let $a="Daniel Chouinard"
let $b = 'Daniel Chouinard'
let $f ="Daniel"+' '+"Chouinard"
let $c='Dan'+$mid("abcdefghijklmnopqrstuvwxyz",8,1)+"el Chouinard"
let $d="Daniel"
let $e='Chouinard'
let $d=$d+" "+$e
let $e=$mid($d,0,6)+' '+$mid($d,7,9999)
print "Current time: "+$mid($time(),11,8)+"\n"
if "toto"!="toto" goto strerr
if "toto"="tata" goto strerr
if "toto"="toto" goto continue
:strerr
print "String Comparison"
goto error
:continue
if "\r"!="^m" print "\\r != \^m" goto error
if "\t"!="^i" print "\\t != \^i" goto error
if '\n'!='^j' print "\\n != \^j" goto error
if "\b"!="^h" print "\\b != \^h" goto error
if "\032"!="^z" print "\\032 != \^z" goto error
if "\134"!="\\" print "\\134 != \\" goto error
if "aardvark" > "beatles" print "String Greater than" goto error
if "beatrice" < "andrew" print "String less than" goto error
if $a!=$b print "String Simple assignment" goto error
if $a!=$f print "String Simple concatenation" goto error
if $a!=$c print "String Simple $mid()" goto error
if $a!=$d print "String replacement" goto error
if $a!=$e print "$mid() went overboard" goto error
print "All String tests Ok!\n"
let a=1
let b=2
if b != b print "Integer comparison" goto error
if a = b print "Integer comparison" goto error
if a>b print "Integer greater than" goto error
if b<a print "Integer less than" goto error
if a!=a print "Integer not equal" goto error
let a=time()
sleep 1.2
if time()=a print "time() or sleep" goto error
hset 30
let a=htime()
print "hset 30 htime() returns ",a,"\n"
if a<25 print "hset or htime()" goto error
if a>45 print "hset or htime()" goto error
sleep 0.3
hset 0
sleep 0.01
let a=htime()
print "0.01 second sleep measured ",a,"/100th of a second.\n"
sleep 0.3
hset 0
sleep 0.1
let a=htime()
print "0.1 second sleep measured ",a,"/100th of a second.\n"
sleep 0.3
hset 0
sleep 0.5
let a=htime()
print "0.5 second sleep measured ",a,"/100th of a second.\n"
sleep 0.3
hset 0
sleep 1
let a=htime()
print "1 second sleep measured ",a,"/100th of a second. "
if a<50 print " (too low)" goto error
if a>200 print " (too high)" goto error
print "\n"
if len($a)!=16 print "len()" goto error
if val("245")!=245 print "val()" goto error
let $h=$rpipe("date")
print '$rpipe("date")="',$h,'"\n'
let a=len($time())
if a!=24 print "$time() returned a ",a," character string" goto error
print '$time()="',$time(),'"\n'
putenv "DCTEST=This is a test"
if % != 0 print "Could not putenv" goto error
if $env("DCTEST")!="This is a test" print "putenv & env do not agree" goto error
let $g=$rpipe("/bin/echo $DCTEST")
if $g!="This is a test" print "putenv didn't export" goto error
let $i="542"
if val($i)!=542 print "val()" goto error
if atol($i)!=542 print "atol()" goto error
if $ltoa(atol($ltoa(atol($i))))!=$i print "$ltoa(atol())" goto error
if 42&27 != 10 print "& (and operator)" goto error
if 42|27 != 59 print "| (or operator)" goto error
if 42^27 != 49 print "\^ (xor operator)" goto error
if 2+2!=4 print "Simple addition" goto error
if 5-3-1 = 3 print "Warning: This version of dcon has the brain-dead getvalue()!\n"
if 5-3-1 = 1 print "This version of dcon has a better getvalue()\n"
if 5-(3-1) != 3 print "Getvalue()" goto error
if (5-3)-1 != 1 print "Getvalue()" goto error
fork
let p=%
if p = -1 print "fork" goto error
if p = 0 sleep 1 print "Child: Terminating.\n" sleep 0.5 exit 0
sleep 0.5 print "Parent: Waiting for child to terminate...\n"
wait
if % != p print "Parent: Wait terminated with the wrong process number!"
else print "Parent: child terminated.\n"
:ftest
let $k="/tmp/dcon.toto"
system "rm -f "+$k
let $j="This is dcon writing to a file."
open file $k
fprint $j,"\n"
close file
let $l=$rpipe("cat -s "+$k)
if $j!=$l print "system(), open file, or fprint" goto error
system "rm -f "+$k
print "All tests ran fine.\n"
exit 0